﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Common.Model;
using Common.Error;
using OpenAPI.Model.API;
using OpenAPI.IDAL.API;
using OpenAPI.DALFactory.API;

namespace OpenAPI.BLL.API
{
    public class MethodManager
    {
        private static readonly IMethod dal = DataAccess.CreateMethod();

        #region 分类管理

        /// <summary>
        /// 新增分类
        /// </summary>
        /// <param name="category"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool AddCategory(MethodCategoryInfo category, out ErrorType error)
        {
            return dal.AddCategory(category, out error);
        }

        /// <summary>
        /// 更新分类
        /// </summary>
        /// <param name="category"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool ModifyCategory(MethodCategoryInfo category, out ErrorType error)
        {
            return dal.ModifyCategory(category, out error);
        }

        /// <summary>
        /// 删除分类
        /// </summary>
        /// <param name="category_cd"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool DeleteCategory(string category_cd, out ErrorType error)
        {
            return dal.DeleteCategory(category_cd, out error);
        }

        /// <summary>
        /// 获取某个分类
        /// </summary>
        /// <param name="category_cd"></param>
        /// <returns></returns>
        public static MethodCategoryInfo GetCategory(string category_cd)
        {
            return dal.GetCategory(category_cd);
        }

        /// <summary>
        /// 获取分类列表
        /// </summary>
        /// <returns></returns>
        public static IList<MethodCategoryInfo> GetCategories()
        {
            return dal.GetCategories();
        }

        #endregion

        #region 方法管理

        /// <summary>
        /// Add Method
        /// </summary>
        /// <param name="method"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool Add(MethodInfo method, out ErrorType error)
        {
            return dal.Add(method, out error);
        }

        /// <summary>
        /// Modify Method
        /// </summary>
        /// <param name="method"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool Mod(MethodInfo method, out ErrorType error)
        {
            return dal.Mod(method, out error);
        }

        /// <summary>
        /// delete method
        /// </summary>
        /// <param name="method_name"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool Delete(string method_name, out ErrorType error)
        {
            return dal.Delete(method_name, out error);
        }

        /// <summary>
        /// 获取API方法
        /// </summary>
        /// <param name="used_yn">是否使用：Y/N，如果传空值，则获取全部</param>
        /// <returns></returns>
        public static IList<MethodInfo> GetMethods(string used_yn)
        {
            return dal.GetMethods(used_yn);
        }

        /// <summary>
        /// 获取API方法详情
        /// </summary>
        /// <param name="method_name"></param>
        /// <returns></returns>
        public static MethodInfo GetMethod(string method_name)
        {
            return dal.GetMethod(method_name);
        }


        #endregion

        #region 参数管理

        /// <summary>
        /// 新增签名参数
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool AddSignArgument(MethodSignArgumentInfo argument, out ErrorType error)
        {
            return dal.AddSignArgument(argument, out error);
        }

        /// <summary>
        /// 删除签名参数
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool DeleteSignArgument(string method_name, string argument_name, out ErrorType error)
        {
            return dal.DeleteSignArgument(method_name, argument_name, out error);
        }


        /// <summary>
        /// 新增非签名参数
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool AddUnSignArgument(MethodUnSignArgumentInfo argument, out ErrorType error)
        {
            return dal.AddUnSignArgument(argument, out error);
        }

        /// <summary>
        /// 删除非签名参数
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool DeleteUnSignArgument(string method_name, string argument_name, out ErrorType error)
        {
            return dal.DeleteUnSignArgument(method_name, argument_name, out error);
        }


        /// <summary>
        /// 获取某个方法的参数（不需签名）
        /// </summary>
        /// <param name="api_method"></param>
        /// <returns></returns>
        public static IList<MethodUnSignArgumentInfo> GetUnSignArguments(string api_method)
        {
            return dal.GetUnSignArguments(api_method);
        }

        /// <summary>
        /// 获取某个方法的参数（需签名）
        /// </summary>
        /// <param name="api_method"></param>
        /// <returns></returns>
        public static IList<MethodSignArgumentInfo> GetSignArguments(string api_method)
        {
            return dal.GetSignArguments(api_method);
        }

        #endregion



    }//
}//
